import Vue from 'vue'
import VueRouter from 'vue-router'

// import Login from '../views/login/index.vue'

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        // name: 'layout', // 如果父路由有默认子路由，则它的name没有意义
        component: () => import('@/views/layout/index.vue'), // 懒加载的方式引入组件
        children: [
            {
                path: '', // 留空，表示默认子路由
                name: 'home',
                component: () => import('@/views/home')
            },
            {
                path: 'qa',
                name: 'qa',
                component: () => import('@/views/qa')
            },
            {
                path: 'video',
                name: 'video',
                component: () => import('@/views/video')
            },
            {
                path: '/my', // 父路由为 / ，子路由 / 可加可不加
                name: 'my',
                component: () => import('@/views/my')
            }
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/views/login/index.vue')
    },
    {
        path: '/search',
        name: 'search',
        component: () => import('@/views/search')
    },
    {
        path: '/article/:articleID',
        name: 'article',
        component: () => import('@/views/article'),
        props: true
    },
    {
        path: '/user/profile',
        name: 'user-profile',
        component: () => import('@/views/user-profile')
    }
]

const router = new VueRouter({
    routes
})

export default router
